import  {  NextRequest, NextResponse } from 'next/server'
import { connectDB,TopicsModel } from '@/app/lib/db'

export const GET = ( ) =>{
  connectDB()
  return  NextResponse.json({msg:'ok'},{status:200})
}


export const POST = async ( request:NextRequest) =>{
  const {title,describe} = await request.json()
  console.log(title)
  try {
    // 数据库操作
    await TopicsModel.create({
      title,describe
    })
    return  NextResponse.json({msg:'create ok'},{status:200})
  } catch (error) {
    return  NextResponse.json({msg:'create error'},{status:500})
  }
}
